extends Area2D

var damage = 10
#存储速度方向
var speed_direction = Vector2()

func _spawn_ready() -> void:
    var relative_position = to_local(Global.core_position)
    speed_direction = relative_position.normalized()
    await get_tree().create_timer(3).timeout
    queue_free()

func _physics_process(delta: float) -> void:
    #子弹移动逻辑
    position += speed_direction * delta * 750

func _on_area_entered(area: Area2D) -> void:
    #检测碰撞，发出信号
    if area.is_in_group("core"):
        Global.current_hp -= damage
        queue_free()
    elif area.is_in_group("core_attack"):
        area.queue_free()
        queue_free()
